﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QuanLyTruongMamNon.Man_Hinh
{
    public partial class frmGiao_Vien : Form
    {
        public frmGiao_Vien()
        {
            InitializeComponent();
        }
        static public DataTable Tao_Bang(string sql)
        {
            DataTable dt = Thu_Vien.ExecuteQuery(sql);
            return dt;
        }
        private void Hienthdanhsach()
        {
            string sql = "select * from GIAO_VIEN";
            DataTable dt=new DataTable();
            dt = Tao_Bang(sql);


            dtgGV.DataSource = dt;
           
            txtMagV.DataBindings.Add("Text", dt, "MaGV");
            txtTen.DataBindings.Add("Text", dt, "HoTenGV");
            txtNgaySinh.DataBindings.Add("Text", dt, "NgaySinh");
            txtTruong.DataBindings.Add("Text", dt, "TotNghiepTruong");

            cboChucVu.DataBindings.Add("text", dt, "ChucVu");
            cboChucVu.Items.Add("Hieu Truong");
            cboChucVu.Items.Add("Hieu Pho");
            cboChucVu.Items.Add("Giao Vien");
            cboChucVu.SelectedItem = 0;

            cboNhom_ND.DataBindings.Add("text", dt, "Manhom_nd");
            int i = 0;
            for (i = 1; i <= 3; i++)
            {
                cboNhom_ND.Items.Add(i);
            }

            cboTrdo.DataBindings.Add("text", dt, "TrinhDo");
            cboTrdo.Items.Add("Dai hoc");
            cboTrdo.Items.Add("Cao dang");
            cboTrdo.Items.Add("Trung cap");
            cboTrdo.Items.Add("THCS");


            cboPhai.DataBindings.Add("text", dt, "gioitinh");
            cboPhai.Items.Add(0);
            cboPhai.Items.Add(1);
            cboPhai.SelectedIndex = 0;

            txtMatKhau.DataBindings.Add("text", dt, "MatKhau");

        }
        private void Giao_Vien_Load(object sender, EventArgs e)
        {
            Hienthdanhsach();

        }


        private void cboThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btThem_Click(object sender, EventArgs e)
        {
                string sql;
                //if ((txtMagV))
                //{
                //    MessageBox.Show("Ban chua nhap Ma Giao Vien");
                   
                //}
                //string lenh="Select count(*) from GIAO_VIEN where MaGV=txtMagV";
                //int dem = Thu_Vien.ExecuteNonQuery(lenh);
                //if(lenh>0)
                //{
                //    MessageBox.Show("Giao vien nay da co roi");
                //}
                txtMagV.Text = "";
                sql="Insert into GIAO_VIEN set MaGV=txtMagV, Hotengv=txtTen, Gioitinh=cboPhai.SelectedItem, Trinhdo=cboTrdo.SelectedItem,chucvu=cboChucVu.SelectedItem, Matkhau=txtMatKhau,Manhom_ND=cboNhom_ND.SelectedItem";
                Thu_Vien.ExecuteNonQuery(sql);
          }

       

       
    }
}
